use std::collections::HashMap;
use std::sync::{Mutex, MutexGuard};

use lazy_static::lazy_static;

use crate::core::base::logger::Logger;
use crate::core::model::data::Data;
use crate::std_::{self, StdFunc};

pub mod logger;
pub mod util;
pub mod meta;
pub mod key_word;

pub type RefDataInfo = (String, String);

lazy_static! {
    pub static ref LOGGER : Mutex<Logger> = Mutex::new(Logger::default());
    pub static ref GLOBAL_VAR : Mutex<HashMap<String,Data>> = Mutex::new(HashMap::new());
    pub static ref YUZU_VAR : Mutex<HashMap<String,HashMap<String,Data>>> = Mutex::new(HashMap::<String,HashMap<String,Data>>::new());
    pub static ref YUZU_REF : Mutex<HashMap<String,HashMap<String,RefDataInfo >>> = Mutex::new(HashMap::<String,HashMap<String,RefDataInfo >>::new());

    pub static ref STD_FUNC : HashMap<String, StdFunc> = std_::init_std_fn();
}

pub fn log() -> MutexGuard<'static, Logger> {
    LOGGER.lock().unwrap()
}

pub fn global_var() -> MutexGuard<'static, HashMap<String, Data>> { GLOBAL_VAR.lock().unwrap() }

pub fn yuzu_var() -> MutexGuard<'static, HashMap<String, HashMap<String, Data>>> { YUZU_VAR.lock().unwrap() }

pub fn yuzu_ref() -> MutexGuard<'static, HashMap<String, HashMap<String, RefDataInfo>>> { YUZU_REF.lock().unwrap() }

